<?php

namespace app\common\services;

class MoneyServices
{
    //积分兑换的比例算法
    public static function scoremoney(){
        //查询pay_shop_rangli
        $moneyLogsSumAll = model('app\common\model\MoneyLog')->where('type','pay_shop_rangli')->sum('money');
        //所有的让利额
        $moneyLogsSum = model('app\common\model\MoneyLog')->where('type','dui_money')->sum('money');
        //剩余
        $balance = bcsub($moneyLogsSumAll,$moneyLogsSum,2);
        if($balance == 0){
            return 0;
        }
        //获取全平台剩余共富积分
        $gf_scores = model('app\common\model\User')->where('gf_score','>',0)->sum('gf_score');
        return bcdiv($gf_scores,$balance,4);
    }
}